<?#//v.3.1.0


		#///////////////////////////////////////////////////////
		#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
		#///////////////////////////////////////////////////////


		include "./includes/config.inc.php";
		$TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));
		$NOW = date("YmdHis",$TIME);

		#// If user is not logged in redirect to login page
		if(!isset($_SESSION["PHPAUCTION_LOGGED_IN"]))
		{
			Header("Location: user_login.php");
			exit;
		}
		if($_POST[action] == "upload")
		{
		#// Process file
		$starts = $NOW;
		$query = "SELECT * FROM PHPAUCTIONXL_users where nick='$_SESSION[PHPAUCTION_LOGGED_IN_USERNAME]'";
		$result = mysql_query($query);
		if (!$result)
		{
				MySQLError($query);
				exit;
		}
		$user_id = mysql_result ($result,0,"id");
		$new_file = "$image_upload_path$user_id.txt";
		if ( file_exists($new_file) )
			unlink ($new_file);
		$file=$HTTP_POST_FILES['file']['tmp_name'];			
		move_uploaded_file("$file", "$new_file");
		chmod($new_file,0666);
		$fcontents = file ($new_file);
		unlink ($new_file);

		// Gian, learn a PHP trick! your friend F.
		foreach ($fcontents as $line_num=>$line)
		{
			list($title,
				$desc,
				$cat,
				$price,
				$res_price,
				$auc_type,
				$incr,
				$loc,
				$zip,
				$ship_exp,
				$ship,
				$quant,
				$bn_only,
				$adultonly)=explode("\t",$line);
			#// Insert into database with closed auction sign
			if ($ship=="2") { $ship=0; }
	
			if (($user_id) && ($title))
			{
				$query = "INSERT INTO PHPAUCTIONXL_auctions values (NULL,
				$user_id,
				'".addslashes($title)."',
				'$starts',
				'".addslashes($desc)."',
				'',
				'$cat',
				'$price',
				'$res_price',
				'',
				'$auc_type',
				'',
				'$incr',
				'$loc',
				'$zip',
				'$ship_exp',
				'',
				'$ship',
				'$starts',
				'',
				'0',
				'',
				'$quant',
				'8',
				'n',
				0,
				0,
				0,
				'n',
				'',
				'$bn_only',
				'$adultonly')";
				$result = mysql_query($query);
				if (!$result)
				{
					MySQLError($query);
					exit;
				}
	
				$MSG = $MSG_737;
			}
		}
		include "header.php";
		include phpa_include("template_bulkupload_php.html");
		include "footer.php";
		exit;

	}

	if(!isset($_POST[action]) || ($_POST[action] == "upload" && isset($ERR)))
	{
		include "header.php";
		include phpa_include("template_bulkupload_php.html");
		include "footer.php";
		exit;
	}
?>
